package com.kingwang.training.designpattern.state.bo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Lift {
    private LiftState state;

    public void openDoor() {
        this.state = this.state.open();
    }

    public void closeDoor() {
        this.state = this.state.close();
    }

    public void run() {
        this.state = this.state.run();
    }

    public void stop() {
        this.state = this.state.stop();
    }

    /**
     * 与状态强关联的行为委托到状态类中的方法去执行
     */
    public void doSomething() {
        this.state.doSomething();
    }
}
